home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / Preinstalled MacPerl (FAT) / t / lib / posix.t < prev    next >
Encoding:
Text File  |  1995-10-31  |  1.8 KB  |  78 lines  |  [TEXT/McPL]

  1. #!./perl
  2.  
  3. BEGIN {
  4.     chdir 't' if -d 't';
  5.     chdir '::' unless -d 'lib';
  6. #    @INC = '../lib';
  7.     @INC = '::lib';
  8.     require Config; import Config;
  9.     if ($Config{'extensions'} !~ /\bPOSIX\b/) {
  10.     print STDERR "1..0\n";
  11.     exit 0;
  12.     }
  13. }
  14. use FileHandle;
  15. use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read write);
  16. use strict subs;
  17.  
  18. $mystdout = new_from_fd FileHandle 1,"w";
  19. autoflush STDOUT;
  20. autoflush $mystdout;
  21. print "1..16\n";
  22.  
  23. print $mystdout "ok ",fileno($mystdout),"\n";
  24. write(1,"ok 2\nnot ok 2\n", 5);
  25.  
  26. $testfd = open("TEST", O_RDONLY, 0) and print "ok 3\n";
  27. read($testfd, $buffer, 9) if $testfd > 2;
  28. # print $buffer eq "#!./perl\n" ? "ok 4\n" : "not ok 4\n";
  29. print $buffer eq "::Perl -S" ? "ok 4\n" : "not ok 4\n";
  30.  
  31. @fds = POSIX::pipe();
  32. print $fds[0] == $testfd + 1 ? "ok 5\n" : "not ok 5\n";
  33. $writer = FileHandle->new_from_fd($fds[1], "w");
  34. $reader = FileHandle->new_from_fd($fds[0], "r");
  35. print $writer "ok 6\n";
  36. close $writer;
  37. print <$reader>;
  38. close $reader;
  39.  
  40. $sigset = new POSIX::SigSet 1,3;
  41. delset $sigset 1;
  42. if (!ismember $sigset 1) { print "ok 7\n" }
  43. if (ismember $sigset 3) { print "ok 8\n" }
  44. $mask = new POSIX::SigSet &SIGINT;
  45. $action = new POSIX::SigAction 'main::SigHUP', $mask, 0;
  46. sigaction(&SIGHUP, $action);
  47. $SIG{'INT'} = 'SigINT';
  48. kill 'HUP', $$;
  49. sleep 1;
  50. print "ok 12\n";
  51.  
  52. sub SigHUP {
  53.     print "ok 9\n";
  54.     kill 'INT', $$;
  55.     sleep 2;
  56.     print "ok 10\n";
  57. }
  58.  
  59. sub SigINT {
  60.     print "ok 11\n";
  61. }
  62.  
  63. print &_POSIX_OPEN_MAX > $fds[1] ? "ok 13\n" : "not ok 13\n";
  64.  
  65. print getcwd() =~ m#/t$# ? "ok 14\n" : "not ok 14\n";
  66.  
  67. # Pick up whether we're really able to dynamically load everything.
  68. print &POSIX::acos(1.0) == 0.0 ? "ok 15\n" : "not ok 15\n";
  69.  
  70. ungetc STDIN 65;
  71. CORE::read(STDIN, $buf,1);
  72. print $buf eq 'A' ? "ok 16\n" : "not ok 16\n";
  73.  
  74. flush STDOUT;
  75. autoflush STDOUT 0;
  76. print '@#!*$@(!@#$';
  77. _exit(0);
  78.